/**
 * 项目构建基本配置
 * 提示：接口服务代理请修改下面的【 proxyTable 】选项！！
 */
// see http://vuejs-templates.github.io/webpack for documentation.
var path = require('path')

module.exports = {
  build: {
    env: require('./prod.env'),
    index: path.resolve(__dirname, '../dist/index.html'),
    assetsRoot: path.resolve(__dirname, '../dist'),
    assetsSubDirectory: 'static',
    assetsPublicPath: '',
    productionSourceMap: true,
    productionGzip: false,
    productionGzipExtensions: ['js', 'css'],
    bundleAnalyzerReport: process.env.npm_config_report
  },
  dev: {
    env: require('./dev.env'),
    port: 8080,
    autoOpenBrowser: true,
    assetsSubDirectory: 'static',
    assetsPublicPath: '/',
    useProxy: true,
    proxyTable: {
      '/main/action': {
        target: 'http://stage2.mytijian.cn',
        changeOrigin: true,
        logLevel:'debug',
        pathRewrite: {
          '^/main/action': '/main/action', //根据上面的服务地址判断是 main 还是 main-site
        },
        cookieDomainRewrite: {
          "main-site": "main",
        },
        onProxyRes: function (proxyRes, req, res) {
          let pResCookie = proxyRes.headers['set-cookie']
          if (pResCookie && pResCookie[0]) {
            pResCookie[0] = pResCookie[0].replace('channel-site', 'channel')
            res._headers['set-cookie'] = pResCookie
          }
        }
      },
    },
    cssSourceMap: false
  }
}
